package com.fengye.aop.demo.enums;

import com.fengye.aop.demo.event.WfCompleteEvent;
import com.fengye.aop.demo.event.WfStartEvent;
import com.fengye.aop.demo.service.account.IWorkflowService;
import com.fengye.aop.demo.vo.WorkflowVO;
import lombok.extern.slf4j.Slf4j;
import org.springframework.context.ApplicationEventPublisher;
import org.springframework.stereotype.Component;

@Component
@Slf4j
public enum OperationType {
    
    START {
        @Override
        public void event(IWorkflowService workflowService, ApplicationEventPublisher applicationEventPublisher, WorkflowVO workflowVO) {
            log.info("发布启动流程事件");
            applicationEventPublisher.publishEvent(new WfStartEvent(workflowVO));
        }
    },
    COMPETE {
        @Override
        public void event(IWorkflowService workflowService, ApplicationEventPublisher applicationEventPublisher, WorkflowVO workflowVO) {
            log.info("发布审批事件");
            applicationEventPublisher.publishEvent(new WfCompleteEvent(workflowVO));
        }
    },
    SIGNAL {
        @Override
        public void event(IWorkflowService workflowService, ApplicationEventPublisher applicationEventPublisher, WorkflowVO workflowVO) {
            log.info("发布信号事件");
        }
    },
    CANCEL {
        @Override
        public void event(IWorkflowService workflowService, ApplicationEventPublisher applicationEventPublisher, WorkflowVO workflowVO) {
            log.info("发布取消事件");
        }
    },
    TRANSFER {
        @Override
        public void event(IWorkflowService workflowService, ApplicationEventPublisher applicationEventPublisher, WorkflowVO workflowVO) {
            log.info("发布转审事件");
        }
    };
    
    public abstract void event(IWorkflowService workflowService, ApplicationEventPublisher applicationEventPublisher, WorkflowVO workflowVO);
}
